use chrono::{DateTime, Local, NaiveDateTime, Duration};
use std::time::{SystemTime, UNIX_EPOCH};

fn timestamp1() -> i64 {
    let start = SystemTime::now();
    let since_the_epoch = start
        .duration_since(UNIX_EPOCH)
        .expect("Time went backwards");
    let ms = since_the_epoch.as_secs() as i64 * 1000i64 + (since_the_epoch.subsec_nanos() as f64 / 1_000_000.0) as i64;
    ms
}

fn main() {
    let now:NaiveDateTime = Local::now().naive_local();
    println!("{:?}", now);

    let start_day = now.format("%Y-%m-%d %H:%M:%S").to_string();
    println!("{}", start_day);
    
    let end_time = NaiveDateTime::parse_from_str("2020-11-22 18:36:27", "%Y-%m-%d %H:%M:%S").unwrap_or(now);
    println!("{:?}", end_time);

    // let sub_time = end_time.sub(Duration::minutes(9));
    // println!("{:?}", sub_time);

    let ts1 = timestamp1();
    println!("TimeStamp1: {}", ts1);

    let func1= |u :u64| -> u64 {u};

    let func2 = |u :u64| {u};

    let func3 = |u :u64| u ;
 
    println!("func1 = {}", func1(46));
    println!("func2 = {}", func2(46));
    println!("func3 = {}", func3(46));
}
